'''
Author: SUNNY
Description: 
Date: 2025-11-16 06:56:59
'''
"""
HTTP 客户端测试脚本
用于测试生产环境下的 MCP 服务器
"""

from fastmcp import Client
import asyncio

async def test_http_server():
    """测试 HTTP 服务器功能"""
    print("🔧 开始测试 HTTP 服务器...")

    try:
        # 连接到HTTP服务器
        async with Client("http://127.0.0.1:8000/mcp") as client:
            print("✅ HTTP服务器连接成功！")

            # 测试工具调用
            result = await client.call_tool("add", {"a": 15, "b": 25})
            print(f"🔢 计算结果：15 + 25 = {result.content[0].text}")

            result = await client.call_tool("multiply", {"a": 6.5, "b": 4.2})
            print(f"🔢 计算结果：6.5 × 4.2 = {result.content[0].text}")

            print("🎉 HTTP服务器测试通过！")

    except Exception as e:
        print(f"❌ HTTP测试失败: {e}")
        print("💡 提示: 请确保HTTP服务器正在运行 (python http_server.py)")

if __name__ == "__main__":
    asyncio.run(test_http_server())